package com.utils;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public class ThreadUtil {
	public static ThreadFactory createThreadFactory(final String name) {
		return new ThreadFactory() {
			final ThreadFactory defaultFactory = Executors.defaultThreadFactory();

			@Override
			public Thread newThread(final Runnable r) {
				Thread thread = defaultFactory.newThread(r);
				thread.setName(name + "-" + thread.getName());
				// thread.setDaemon(true);
				return thread;
			}
		};
	}
	
	public static void sleep(long millis){
		try {
			Thread.sleep(millis);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
